<template>
	<view class="customPage">
		<image :src="url" mode="widthFix" class="img"></image>
		<view class="btnBox">
			<u-button type="primary" @click="saveImg" class="btn" :custom-style="{
			background: 'black',
			color: 'white',
			borderRadius: '50rpx'}">保存发票</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: '',
			};
		},
		methods: {
			saveImg: function () {
				uni.getImageInfo({
					src: this.url,
					success: res => {
						console.log(res)
						uni.saveImageToPhotosAlbum({
							filePath: res.path,
							success: () => {
								uni.showToast({
									title: '保存成功',
									icon: 'success'
								})
							}
						})
					}
				})
			},
		},
		onLoad: function (option) {
			const { url } = option
			this.url = url || ''
		}
	}
</script>

<style lang="scss">
	.customPage{
		padding: 300rpx 30rpx 0 30rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.img{
		max-width: 100%;
	}
	.btnBox{
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background: white;
		z-index: 5;
		padding: 20rpx 30rpx calc(20rpx + env(safe-area-inset-bottom)) 30rpx;
		.btn{
		}
	}
</style>
